<%@page contentType="text/html; charset=utf-8" %>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/messages.jsp"%>
<%@ include file="/commons/commonEdit.jsp" %>
<%@ include file="/commons/validation.jsp" %>
<%@ include file="/commons/dateTime.jsp" %>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>业户回访</title>
<script type="text/javascript" src="${ctx}/scripts/global.js"></script>
<script type="text/javascript" src="${ctx}/scripts/div/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/public.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common/prototype.js"></script>
<script type="text/javascript" src="${ctx}/scripts/common.js"></script>
<script type="text/javascript" src="${ctx}/scripts/ajaxException.js"></script>

<script type="text/javascript">
function choiceHouse(){
	var ownerUrl = "${ctx}/customer_chooseSingleHouseAction.do?method=chooseBuildingMain";
	ownerUrl += "&parentFrameId=editPageIfm";
	top.windowOpen(ownerUrl , "chooseBuildFrm", "选择房间",500,800);
}

function setHouseInfo(houseId,houseNum){
		document.getElementById("houseId").value = houseId;
		document.getElementById("houseNumber").value = houseNum;
		$('houseNumber').fireEvent("onblur");
}

function addOwnersVisit(){
	var isTrue=$('thingEntrustForm').fireEvent("onSubmit") ;
    if(isTrue){
    	document.getElementById('sumitok').disabled = true;
        var param = Form.serialize('thingEntrustForm');
        var url = null;
		if($('keyword').value == ""){
		   url = "${ctx}/customerService_ownersVisitAction.do?method=add";
		}
		else{
			url = "${ctx}/customerService_ownersVisitAction.do?method=edit";
		}
       new Ajax.Request(url,{method: 'post',parameters :param ,onSuccess : showResult});
	}
}

function ajaxSearchHouseInfo(){
	var url = "${ctx}/thing_thingEntrustAction.do?method=queryOwnerHouseInfo";
	var houseId = $F('houseId');
	if(houseId == "")
		return;
	var param = "houseId="+houseId;
	new Ajax.Request(url,{method: 'post', parameters: param, onComplete: showResponse});
}
//选房
function showResponse(result){

	var obj = eval("("+result.responseText+")");
	if("false" == result.responseText){
		Alert("没有业主请重新选择!");
		$('houseNumber').value="";
		$('houseId').value="";
		return false;
	}
	$('owners').value = obj.ownerName;
}

function showResult(response){
	document.getElementById('sumitok').disabled = false;
	ajaxSubmitException(response.responseText);
	if($('keyword').value == ""){
		findFrame('main').cur_p='1';
	}
	findFrame('main').refleshFrame();
	if(response.responseText == "true"){
		windowClose();
    }

}
</script>
</head>
<body>
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2" class="window_head_outBg"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="${ctx}/images/ico_Advance.gif" width="16" height="16" align="absmiddle" /> <span class="window_head_intext">客户走访</span> </td>
      </tr>
    </table></td>
  </tr>
  <tr>
    <td colspan="2" class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td colspan="2" class="aux_header_line_2"></td>
  </tr>
  <tr>
    <td colspan="2" class="content"><table width="100%" border="0" cellspacing="0" cellpadding="0">
      <tr>
        <td class="aux_outtable_color">
            <form action="" method="post" name="thingEntrustForm" class="required-validate">
            <input type="hidden" name="houseId" value="${ownerVisitVO.houseId }">
            <input type="hidden" name="keyword" value="${ownerVisitVO.keyword }">
	        <table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color">
                <tr>
                    <td valign="top" class="aux_intable_td1">房 号：</td>
                    <td valign="top" class="aux_intable_require"><table border="0" cellspacing="0" cellpadding="0">
                        <tr>
                          <td></td>
                          <td></td>
                        </tr>
                        <tr>
                          <td><input name="houseNumber" readonly="readonly" type="text" class="required" size="16" onblur="ajaxSearchHouseInfo()" value="${ownerVisitVO.houseNumber }"/></td>
                          <td width="4">&nbsp;</td>
                          <td><a href="#"  onClick="choiceHouse();" onFocus="this.blur()" ><img src="${ctx}/images/ico_houesno.GIF" alt="请点选查找房号" border="0" /></a></td>
                        </tr>
                    </table></td>
               </tr>
			   <tr>
				  <td valign="top" class="aux_intable_td1">业户姓名： </td>
				  <td valign="middle" class="aux_intable_require">
					<input name="owners" id="owners" type="text" class="required validate-char" size="16" value="${ownerVisitVO.owners }"/>
					</td>
			   </tr>
		       <tr >
		           <td class="aux_intable_td1">访问时间：</td>
		           <td class="aux_intable_td2"><table border="0" cellspacing="0" cellpadding="0">
		               <tr>
		                  <td><input name="visitTime" id="visitTime" type="text" class="validate-dateTime-yyyy-mm-dd-HH:mm" value="<fmt:formatDate value='${ownerVisitVO.visitTime }' pattern='yyyy-MM-dd HH:mm'/>" size="16" afterInsert="dateAfter" /></td>
		                  <td width="4">&nbsp;</td>
		                  <td><img name="acceptDateButton" src="${ctx}/images/ico_clock.gif" width="20" height="20" /><span id="dateAfter"></span></td>
		                </tr>
		            </table></td>
		       </tr>
		       <tr>
				  <td valign="top" class="aux_intable_td1">访问方式： </td>
				  <td valign="middle" class="aux_intable_td2">
				  	<input name="mode" class="validate-char" type="text" id="mode" size="16" value="${ownerVisitVO.mode }"/>
				  </td>
			   </tr>
	           <tr>
	            <td valign="top" class="aux_intable_td1">访问记录：</td>
	            <td valign="top" class="aux_intable_require_more"><textarea name="record" id="record" cols="25" rows="2" class="required max-length-1000">${ownerVisitVO.record }</textarea></td>
	           </tr>
	           <tr>
				<td valign="top" class="aux_intable_td1">备注：</td>
	            <td valign="top" class="aux_intable_td2"><textarea name="remark" id="remark" cols="25" rows="2" class="max-length-500">${ownerVisitVO.remark }</textarea></td>
	           </tr>
		</table>
		</form>
	 </td>
	</tr>
	</table></td></tr>
	<tr>
	    <td class="window_footer">&nbsp;</td>
	    <td class="window_footer"><table border="0" cellspacing="0" cellpadding="0">
	        <tr>
	          <td><table id="sumitok" border="0" cellpadding="0" cellspacing="0" onclick="addOwnersVisit()">
	            <tr>
	              <td class="buttonOffLeft" id="btn1_21"></td>
	              <td class="buttonOffMiddle" id="btn1_22"  onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)" onblur="btn_change(2)"><img src="${ctx}/images/ico_ok.gif" alt="" width="14" height="14" border="0" align="absbottom" /> 保 存</td>
	              <td class="buttonOffRight" id="btn1_23"></td>
	            </tr>
	        </table></td>
	          <td class="btn_between_space"></td>
	          <td><table border="0" cellpadding="0" cellspacing="0">
	              <tr>
	                <td class="buttonOffLeft" id="btn1_31"></td>
	                <td class="buttonOffMiddle" id="btn1_32" onClick="windowClose();" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)" onBlur="btn_change(3)"><img src="${ctx}/images/ico_cancel.gif" alt="" width="14" height="14" border="0" align="absbottom" /> 关 闭</td>
	                <td class="buttonOffRight" id="btn1_33"></td>
	              </tr>
	          </table></td>
	        </tr>
           </table></td>
    </tr>
</table>
<script type="text/javascript">
Calendar.setup(
              {
	              inputField : "visitTime", // ID of the input field
	              ifFormat : "%Y-%m-%d %H:%M", // the date format
	              button : "acceptDateButton", // ID of the button
	              align          :    "Tl",           // alignment (defaults to "Bl")
			      singleClick    :    true,
			      showsTime : true
              }
              );
</script>
</body>
</html>